package com.atguigu.srb.core.controller.admin;


import com.atguigu.srb.common.result.R;
import com.atguigu.srb.core.pojo.entity.BorrowInfo;
import com.atguigu.srb.core.pojo.vo.BorrowInfoApprovalVO;
import com.atguigu.srb.core.service.BorrowInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 借款信息表 前端控制器
 * </p>
 *
 * @author Mr.bilal
 * @since 2023-07-18
 */
@RestController
@RequestMapping("/admin/core/borrowInfo")
public class AdminBorrowInfoController {

    @Autowired
    BorrowInfoService borrowInfoService;
    @GetMapping("/getList")
    public R getList(){
        List<BorrowInfo> list = borrowInfoService.selectList();
        return R.ok().data("list",list);
    }

    @GetMapping("/show/{borrowInfoId}")
    public R show(@PathVariable Long borrowInfoId){
        Map<String, Object> borrowInfoDetail = borrowInfoService.show(borrowInfoId);
        return R.ok().data("borrowInfoDetail",borrowInfoDetail);
    }

    @PostMapping("approvalSubmit")
    public R approvalSubmit(@RequestBody BorrowInfoApprovalVO borrowInfoApprovalVO){
        borrowInfoService.approvalSubmit(borrowInfoApprovalVO);
        return R.ok();
    }

}

